cmake_minimum_required(VERSION 2.8)
project(HikvisionCtrl)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall -Wno-strict-aliasing -Wno-unused-variable")

include_directories(
        common/sand
        common/mpack
        common/jsoncpp/json
)

SET(sand_src
        common/sand/sand.cpp
        )
SET(mpack_src
        common/mpack/mpack.cpp
        common/mpack/mpack.h
        common/mpack/mpack-config.h
        )
SET(jsoncpp_src
        common/jsoncpp/jsoncpp.cpp
        )

INCLUDE_DIRECTORIES(
	    #./include/msgpack-c
        ./include/filesystem
        ./include/hcnetsdk
        ./include/curlcpp
        ./include/mqtt
        ./include
        ./
        /usr/local/include
)
LINK_DIRECTORIES(
        ${PROJECT_SOURCE_DIR}/lib
        /usr/lib/x86_64-linux-gnu/
		/usr/local/lib/
        /usr/lib/
)

find_library(MOSQUITTOLIB mosquitto PATHS ${PROJECT_SOURCE_DIR}/usr/local/lib /usr/lib /usr/local/lib/ /usr/lib/x86_64-linux-gnu DOC "modbus library")
if(NOT MOSQUITTOLIB)
    message(FATAL_ERROR "libmosquitto not found")
endif()

FILE(GLOB mqtt_src common/mqtt/mosquittopp.cpp)
ADD_LIBRARY(common_mqtt SHARED ${mqtt_src})
TARGET_LINK_LIBRARIES(common_mqtt pthread ${MOSQUITTOLIB})

set(SOURCE_FILES
        ${sand_src}
        ${mpack_src}
        ${jsoncpp_src}
        src/ctrl_serv.cpp
        src/hikv_api.cpp
        src/ctrl_cfg.cpp
        src/ctrl_spdlog.cpp src/ctrl_app.h src/ctrl_app.cpp src/ctrl_utils.h src/ctrl_utils.cpp)

add_executable(HikvisionCtrl ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(HikvisionCtrl pthread dl curlcpp curl X11 yaml-cpp hcnetsdk common_mqtt)

#INSTALL(TARGETS HikvisionCtrl common_mqtt
#        RUNTIME DESTINATION /usr/sbin
#        LIBRARY DESTINATION /usr/lib
#        )
